<#-- 选人还是选部门 -->
<select class="form-control" style="width: 120px;" name="receiverType">
	<option value="">--请选择--</option>
	
	<#if action == "add">
		<#-- 新增页面 -->
		<#if userType == 1>
			<option value="12">上报</option>
			<option value="13">内部员工</option>
		<#elseif userType == 2>
			<option value="7">上报</option>
			<option value="8">内部员工</option>
		<#elseif userType == 3>
			<option value="1">总部用户</option>
			<option value="2">总部部门</option>
		</#if>
	<#elseif action == "handle">
		<#-- 处理页面 -->
		<#if userType == 1>
			<option value="14">上报</option>
			<option value="15">内部员工</option>
		<#elseif userType == 2>
			<option value="9">上报</option>
			<option value="10">内部员工</option>
			<option value="11">代理商</option>
		<#elseif userType == 3>
			<option value="3">总部用户</option>
			<option value="4">总部部门</option>
			<option value="5">代理商</option>
			<option value="6">运营中心</option>
		</#if>
	</#if>
</select>

<#-- 具体到人或具体到部门 -->
<select class="form-control select2" style="width: 320px;" name="receiver" required>
	<option value="">--请选择--</option>
</select>

<script type="text/javascript">
	/* 接收人切换 */
	$("select[name='receiverType']").change(function () {
		$("select[name='receiver']").html('<option value="">--请选择--</option>');
		var receiverType = $(this).val();
		
		$.ajax({
			url : "${ctx}/platManager/loadReceiver",
			type : 'post',
			dataType : 'json',
			data : {"receiverType" : receiverType, 'userType' : '${userType}'},
			success : function(data) {
				if (data.result == 'success') {
					// console.log(JSON.stringify(data.data));
					var receiverData = data.data;
					if (receiverData) {
						for (key in receiverData) {
							$("select[name='receiver']").append('<option value="' + key + '">' + receiverData[key] + '</option>');
						}
					}
				}
			}
		});
	});
	$("select[name='receiver']").change(function () {
		$(this).valid();
	});
</script>
